//
//  RootTabBarVC.m
//  FreeReading
//
//  Created by lanou3g on 15/10/27.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "RootTabBarVC.h"
#import "EnjoyViewController.h"
#import "HotTableViewController.h"
#import "ReadingViewController.h"
#import "MineViewController.h"

@interface RootTabBarVC ()

@end

@implementation RootTabBarVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.tabBar setBackgroundImage:[UIImage imageNamed:@"tabar2"]];
    self.tabBar.tintColor = [UIColor redColor];
  // 创建子控制器
    [self addSubViewControllerWithClass:[EnjoyViewController class] title:@"玩乐" imageName:@"home" selectImageName:@""];
    [self addSubViewControllerWithClass:[HotTableViewController class] title:@"热点" imageName:@"hot" selectImageName:@""];
    [self addSubViewControllerWithClass:[ReadingViewController class] title:@"订阅" imageName:@"reading" selectImageName:@""];
    [self addSubViewControllerWithClass:[MineViewController class] title:@"我的" imageName:@"mine" selectImageName:@""];

}

// 添加子控制器
- (void)addSubViewControllerWithClass:(Class)class title:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectImageName
{
    
    UIViewController *viewController = [[class alloc] init];
    UINavigationController *naVC = [[UINavigationController alloc] initWithRootViewController:viewController];
    naVC.tabBarItem.title = title;
    naVC.tabBarItem.image = [UIImage imageNamed:imageName];
    naVC.tabBarItem.selectedImage = [UIImage imageNamed:selectImageName];
    [self addChildViewController:naVC];
    
}

#pragma mark - 内存警告
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    if ([self isViewLoaded] && self.view.window == nil) {
        
        self.view = nil;
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
